<?php
 /**
 * Joomla! 1.5 component PB-Roster
 *
 * @version $Id: pbroster.php 2010-09-10 10:03:33 svn $
 * @author ML@pixelbyte.dk
 * @package Joomla
 * @subpackage PB-Roster
 * @copyright (C) 2010- pixelbyte.dk
 * @license GNU/GPL
 *
 * A World of Warcraft Guild Roster
 *
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class HTML_MemberRoster {

  function getMemberRights() {
    $user =& JFactory::getUser();
    if($user->id) {
      return true;
    }
    else {
      return false;
    }
  }
  
  function includeMemberDocs() {
    $document = & JFactory :: getDocument();
	$document->addStyleSheet(getRosterPath("roster").'css/main.css');
	$document->addStyleSheet(getRosterPath("roster").'css/guild_roster.css');
	$document->addStyleSheet(getRosterPath("roster").'css/guild_account.css');
	$document->addStyleSheet(getRosterPath("roster").'css/tinybox.css');
	$document->addScript(getRosterPath("roster").'js/jquery-1.4.2.min.js');
	$document->addScript(getRosterPath("roster").'js/core.js');
	$document->addScript(getRosterPath("roster").'js/tooltip.js');
	$document->addScript(getRosterPath("roster").'js/tinybox.js');
  }
  
  function memberFooter() {
    $db =& JFactory::getDBO();
    $query = "SELECT * FROM #__guildroster_main";
    $db->setQuery($query);

	$lostTime = 0;
    $cache = $db->loadObject();
    if( $db->getErrorNum() || !isset($cache) || !isset($cache->cache_date))
	  $lostTime = 1;
	
	echo '<div class="guild_roster_footer">';
	echo '</div>';
  }
  
  function footerButtons() {
    echo '</div></div></div></div></div>'; //rosterHeader()
  }
  
  function headerMenu($config, $active) {
	
    echo '<ul class="profile-sidebar-menu" id="profile-sidebar-menu">';
    if ($config->menu_roster == 'yes') {
      echo '<li class="'.($active == 'roster' ? 'active' : '').'"><a class="has-submenu" title="'.JText::_( 'COM_PBROSTER_MENU_ITEM_ROSTER' ).'" href="'.JRoute::_('index.php?option=com_pbroster&view=pbroster').'"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_MENU_ITEM_ROSTER' ).'</span></span></a></li>'."\n";
    }
    echo '<li class="'.($active == 'account' ? 'active' : '').'"><a title="'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_PROFILE' ).'" href="'.JRoute::_('index.php?option=com_pbroster&view=account').'" class="vault" rel="np"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_PROFILE' ).'</span></span></a></li>'."\n";
	echo '<li class="'.($active == 'claims' ? 'active' : '').'"><a title="'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_CHARACTERS' ).'" href="'.JRoute::_('index.php?option=com_pbroster&view=account&page=claims').'" class="vault" rel="np"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_CHARACTERS' ).'</span></span></a></li>'."\n";
	echo '<li class="'.($active == 'options' ? 'active' : '').'"><a title="'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_OPTIONS' ).'" href="'.JRoute::_('index.php?option=com_pbroster&view=account&page=options').'" class="vault" rel="np"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_OPTIONS' ).'</span></span></a></li>'."\n";
	if (HTML_AdminRoster::getAdminRights()) {
      echo '<li class="'.($active == 'admin' ? 'active' : '').'"><a title="'.JText::_( 'COM_PBROSTER_MENU_ITEM_ADMIN' ).'" href="'.JRoute::_('index.php?option=com_pbroster&view=admin&page=member').'" class="vault" rel="np"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_MENU_ITEM_ADMIN' ).'</span></span></a></li>'."\n";
    }
    else {
      echo '<li class="disabled tooltip_general" onmouseover="Tooltip.show(this, \'#admin_button\');"><a href="javascript:;" class="vault" rel="np"><span class="arrow"><span class="icon">'.JText::_( 'COM_PBROSTER_MENU_ITEM_ADMIN' ).'</span></span></a></li>';
	  echo '<span id="admin_button" style="display: none;"><ul><li><h3>'.JText::_( 'COM_PBROSTER_MENU_ITEM_ADMIN' ).'</h3></li><li class="color-tooltip-yellow">'.JText::_( 'COM_PBROSTER_MENU_TOOLTIP_ADMIN' ).'</li></ul></span>';
    }
  }
  
  function showMemberAccount($claims, $option) {
  
    // get account
	$account =& JFactory::getUser();
	
	HTML_MemberRoster::includeMemberDocs();
	$config = getGuildConfig();
  
	// Modify breadcrumbs
	$mainframe = &JFactory::getApplication();
	$app =& JFactory::getApplication();
	$pathway =& $app->getPathway();
	$pathway->addItem(JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_PROFILE' ).' @ '.ucfirst($account->name));
	
	$ginfo = getGuildInfo();
	foreach ( $ginfo as $guild ) {
	  // Get faction
	  if ($guild->faction == 0)
	    $faction = "alliance";
	  else
	    $faction = "horde";
	}
	
	// Check template setting
    $template = getRosterTemplateAdjust($config);
	
	// Get profile info
	$profile = getAccountProfile($account->id);
	
	// Get main character
	$got_main = false;
	$num_char=0;
	$main->name = "";
	$main->details = "";
	$main->avatar = "";
	foreach ( $claims as $char ) {
	  if ($char->ac_type == 1) {
	    $talent1 = @unserialize($char->talent_spec1);
	    $talent2 = @unserialize($char->talent_spec2);
				
	    $prime_talent = "";
	    $prime_talent['prim'] = "none";
				
	    if (!isset($talent1['prim'])) {
	      $talent1['prim'] = "";
	      $talent1['active'] = 0;
	    }
	    if (!isset($talent2['prim'])) {
	      $talent2['prim'] = "";
	      $talent2['active'] = 0;
	    }
				  
	    if ($talent1['prim'] != "" && $talent1['active'] == 1)
	      $prime_talent = $talent1;
	    else if ($talent2['prim'] != "" && $talent2['active'] == 1)
	      $prime_talent = $talent2;
		  
		$main->name = '<h3 class="subheader name larger color-c'.$char->classId.'">'.$char->name.'</h3>'."\n";
		$main->details = '<div style="margin-top:5px;" class="color-c'.$char->classId.'">'.$char->level.' '.return_race_lang($char->raceId).' '.($prime_talent['prim'] != "none" ? $prime_talent['prim'] : "").' '.return_class_lang($char->classId).'</div>'."\n";
		$main->avatar = '<a href="'.JRoute::_('index.php?option=com_pbroster&view=character&ch='.$char->name).'"><img width="56" height="56" src="'.return_avatar_src($char->avatar, $char->raceId, $char->genderId).'" alt=""/></a><span class="frame"></span>'."\n";
		
		$got_main = true;
	  }
	  $num_char++;
	}
	
?>	
<div class="RosterPage" style="width:<?php echo $config->roster_width; ?>px;<?php echo $template->marginleft.$template->margintop; ?>">
  <div class="content-top">
  <div class="content-trail"> </div>
  <div class="content-bot">
	<div id="profile-wrapper" class="profile-wrapper profile-wrapper-<?php echo $faction; ?>">
	  <div class="profile-sidebar-anchor">
		<div class="profile-sidebar-outer">
		  <div class="profile-sidebar-inner">
			<div class="profile-sidebar-contents">
			  <div class="profile-sidebar-crest">
<?php

	HTML_MemberRoster::headerMenu($config, "account");

?>
			  </div>
			</div>
		  </div>
		</div>
	  </div>
	  <div class="profile-contents">
		<div class="profile-section-header">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_PAGE_TITLE' ); ?></h3>
		</div>
		<div class="profile-section events">
	
		<li class="event-category category-secondary">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_SUB_TITLE_PROFILE' ); ?></h3>
		  <div class="profile-box-simple"></div>

<?php		  
	echo '<div class="content-block"><span class="profile-scroll content-5"><span class="content-title">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_SUB_TITLE_PROFILE' ).'</span><span class="content-desc">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_SUB_DESC_PROFILE' ).'</span></span></div>';
	echo '<li class="event-summary account-form"><p><label for="jname" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_USERNAME' ).'</label><span class="jname">'.$account->username.'</span></p></li>';
	echo '<li class="event-summary account-form"><p><label for="jemail" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_EMAIL' ).'</label><span class="jname">'.$account->email.'</span></p></li>';
	echo '<li class="event-summary account-form"><p><label for="jusertype" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_TYPE' ).'</label><span class="jname">'.getJoomlaUserType().'</span></p></li>';
	
	if ($got_main) {
	  echo '<li class="event-summary"><p><label for="jname" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_MAIN' ).'</label>';
	  echo '<div class="event-header" style="float: left;margin: -12px 0 0;"><span class="icon-frame">'.$main->avatar.'</span><div class="event-header-text">'.$main->name.$main->details.'</div></div></p></li>';
	}
	else
	  echo '<li class="event-summary"><p><label for="jname" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_MAIN' ).'</label><span class="jname">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_DESC_MAIN' ).'</span></p></li>';
	
	echo '<form method="post" action="'.JRoute::_('index.php?option=com_pbroster&view=account&page=save_profile').'" id="form">';
	echo '<li class="event-summary account-form"><p><label for="pro_name" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_NAME' ).'</label><input type="text" id="pro_name" value="'.$profile->name.'" name="pro_name" size="50" maxlength="25" tabindex="1" class="input"/></p></li>';
	echo '<li class="event-summary account-form"><p><label for="surname" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_SURNAME' ).'</label><input type="text" id="surname" value="'.$profile->surname.'" name="surname" size="50" maxlength="25" tabindex="2" class="input"/></p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="country" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_COUNTRY' ).'</label>';
	
	$countries = getCountryList();
	echo '<select id="country" name="country" tabindex="3" class="select">';
	echo '<option value="" '.($profile->country == ""?"selected=\"selected\"":"").'>-- Select your Country --</option>';
	foreach ($countries as $country) {
	  echo '<option value="'.$country->country_name.'" '.($profile->country == $country->country_name?"selected=\"selected\"":"").'>'.$country->country_name.'</option>';
	}
	echo '</select></p></li>';
	
	echo '<li class="event-summary account-form"><p>';
	echo '<label for="dateOfBirth" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_BIRTH' ).' <span class="small">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_DESC_BIRTH' ).'</span></label>';
	echo '<input type="text" id="dateOfBirth" value="'.$profile->dateOfBirth.'" name="dateOfBirth" size="50" maxlength="2" tabindex="4" class="input"/>';
	
	echo '<label id="monthOfBirthLabel" for="monthOfBirth">Month of Birth</label>';
?>
	<select id="monthOfBirth" name="monthOfBirth" tabindex="5" class="select">
	  <option value="" <? echo $profile->monthOfBirth ==0?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_SELECT' ); ?></option>
		<OPTION value="1" <? echo $profile->monthOfBirth ==1?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_1' ); ?></OPTION>
		<OPTION value="2" <? echo $profile->monthOfBirth ==2?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_2' ); ?></OPTION>
		<OPTION value="3" <? echo $profile->monthOfBirth ==3?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_3' ); ?></OPTION>
		<OPTION value="4" <? echo $profile->monthOfBirth ==4?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_4' ); ?></OPTION>
		<OPTION value="5" <? echo $profile->monthOfBirth ==5?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_5' ); ?></OPTION>
		<OPTION value="6" <? echo $profile->monthOfBirth ==6?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_6' ); ?></OPTION>
		<OPTION value="7" <? echo $profile->monthOfBirth ==7?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_7' ); ?></OPTION>
		<OPTION value="8" <? echo $profile->monthOfBirth ==8?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_8' ); ?></OPTION>
		<OPTION value="9" <? echo $profile->monthOfBirth ==9?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_9' ); ?></OPTION>
		<OPTION value="10" <? echo $profile->monthOfBirth ==10?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_10' ); ?></OPTION>
		<OPTION value="11" <? echo $profile->monthOfBirth ==11?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_11' ); ?></OPTION>
		<OPTION value="12" <? echo $profile->monthOfBirth ==12?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_SELECT_MONTH_12' ); ?></OPTION>
	</select>
<?php

	echo '<label id="yearOfBirthLabel" for="yearOfBirth">Year of Birth</label>';
	echo '<input type="text" id="yearOfBirth" value="'.$profile->yearOfBirth.'" name="yearOfBirth" size="50" maxlength="4" tabindex="6" class="input"/>';
	echo '</p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="gender" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_GENDER' ).'</label>';
	echo '<input class="radio" type="radio" value="0" '.($profile->gender ==0?"checked=\"checked\"":"").' name="gender" id="gender" tabindex="7"><label class="inside" for="gender0">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_GENDER_NOTSET' ).'</label>';
	echo '<input class="radio" type="radio" value="1" '.($profile->gender ==1?"checked=\"checked\"":"").' name="gender" id="gender" tabindex="8"><label class="inside" for="gender1">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_GENDER_MALE' ).'</label>';
	echo '<input class="radio" type="radio" value="2" '.($profile->gender ==2?"checked=\"checked\"":"").' name="gender" id="gender" tabindex="9"><label class="inside" for="gender2">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_GENDER_FEMALE' ).'</label>';
	echo '</p></li>';
	echo '<li class="event-summary account-form"><p><label for="web" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_WEB' ).'</label><input type="text" id="web" value="'.$profile->web.'" name="web" size="50" maxlength="150" tabindex="10" class="input"/></p></li>';
	echo '<li class="event-summary account-form"><p><label for="blog" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_BLOG' ).'</label><input type="text" id="blog" value="'.$profile->blog.'" name="blog" size="50" maxlength="150" tabindex="11" class="input"/></p></li>';
	echo '<li class="event-summary account-form"><p><label for="gallery" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_GALLERY' ).'</label><input type="text" id="gallery" value="'.$profile->gallery.'" name="gallery" size="50" maxlength="150" tabindex="12" class="input"/></p></li>';
	echo '<li class="event-summary system-event"><p><label for="comments" class="label">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_LABEL_TITLE_COMMENTS' ).'</label><textarea type="text" id="comments" name="comments" size="50" maxlength="320" tabindex="13" class="input comment">'.$profile->comments.'</textarea></p></li>';
	
	echo '<span class="event-summary account-form"><button type="submit" class="button" value="'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_BUTTON_PROFILE' ).'" name="post" tabindex="14">'.JText::_( 'COM_PBROSTER_ACCOUNT_PROFILE_FORM_BUTTON_PROFILE' ).'</button></span></form>';
	  
		  //<h3 class="category ">Log</h3>
		  //<div class="profile-box-simple"></div>
		  //<ul><li class="empty">There are no events to show.</li></ul>
?>
		</li>
		  <span class="clear"><!-- --></span>
		</div>
	  </div>
	  <span class="clear"><!-- --></span>
	</div>
  </div>
  </div>
</div>

<?php
  
  }
  
  function showMemberOptions($claims, $option) {
    // get account
    $account =& JFactory::getUser();
	
    HTML_MemberRoster::includeMemberDocs();
	$config = getGuildConfig();
	
	// Modify breadcrumbs
	$mainframe = &JFactory::getApplication();
	$app =& JFactory::getApplication();
	$pathway =& $app->getPathway();
	$pathway->addItem(JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_OPTIONS' ).' @ '.ucfirst($account->name));
	
	$ginfo = getGuildInfo();
	foreach ( $ginfo as $guild ) {
	  // Get faction
	  if ($guild->faction == 0)
	    $faction = "alliance";
	  else
	    $faction = "horde";
	}
	
	// Check template setting
    $template = getRosterTemplateAdjust($config);
	
	// Get profile info
	$options = getAccountOptions($account->id);
	
?>	
<div class="RosterPage" style="width:<?php echo $config->roster_width; ?>px;<?php echo $template->marginleft.$template->margintop; ?>">
  <div class="content-top">
  <div class="content-trail"> </div>
  <div class="content-bot">
	<div id="profile-wrapper" class="profile-wrapper profile-wrapper-<?php echo $faction; ?>">
	  <div class="profile-sidebar-anchor">
		<div class="profile-sidebar-outer">
		  <div class="profile-sidebar-inner">
			<div class="profile-sidebar-contents">
			  <div class="profile-sidebar-crest">
<?php

	HTML_MemberRoster::headerMenu($config, "options");

?>
			  </div>
			</div>
		  </div>
		</div>
	  </div>
	  <div class="profile-contents">
		<div class="profile-section-header">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_PAGE_TITLE' ); ?></h3>
		</div>
		<div class="profile-section events">
	
		<li class="event-category category-secondary">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_SUB_TITLE_OPTIONS' ); ?></h3>
		  <div class="profile-box-simple"></div>

<?php		  
	echo '<div class="content-block"><span class="profile-scroll content-1"><span class="content-title">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_SUB_TITLE_OPTIONS' ).'</span><span class="content-desc">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_SUB_DESC_OPTIONS' ).'</span></span></div>';
	
	echo '<form method="post" action="'.JRoute::_('index.php?option=com_pbroster&view=account&page=save_options').'" id="form">';
	
	echo '<li class="event-summary account-form"><p><label for="table_default" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_COLUMN' ).'</label>';
?>	
	<select id="table_default" name="table_default" class="select option">
	  <option value="-1" <? echo $options->table_default == -1 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_DEFAULT' ); ?></option>
	  <option value="0" <? echo $options->table_default == 0 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_LEVEL' ); ?></option>
	  <option value="1" <? echo $options->table_default == 1 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_NAME' ); ?></option>
	  <option value="2" <? echo $options->table_default == 2 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_POINTS' ); ?></option>
	  <option value="3" <? echo $options->table_default == 3 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_RACE' ); ?></option>
	  <option value="4" <? echo $options->table_default == 4 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_CLASS' ); ?></option>
	  <option value="5" <? echo $options->table_default == 5 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_ROLE' ); ?></option>
	  <option value="6" <? echo $options->table_default == 6 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_PRO1' ); ?></option>
	  <option value="7" <? echo $options->table_default == 7 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_PRO2' ); ?></option>
	  <option value="8" <? echo $options->table_default == 8 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_ILEVEL' ); ?></option>
	  <option value="9" <? echo $options->table_default == 9 ?"selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_RANK' ); ?></option>
	</select>
<?php
	echo '</p></li>';
	echo '<li class="event-summary account-form"><p><label for="table_sort" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_DIRECTION' ).'</label>';
?>	
	<select size="1" id="table_sort" name="table_sort" class="select option">
	  <option value="0" <? echo $options->table_sort == 0 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_DEFAULT' ); ?></option>
	  <option value="1" <? echo $options->table_sort == 1 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_ASC' ); ?></option>
	  <option value="-1" <? echo $options->table_sort == -1 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_DESC' ); ?></option>
	</select>
<?php
	echo '</p></li>';
	echo '<li class="event-summary account-form"><p><label for="table_entries" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_ENTRIES' ).'</label>';
?>		
	<select id="table_entries" name="table_entries" class="select option">
	  <option value="0" <? echo $options->table_entries == 0 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_DEFAULT' ); ?></option>
	  <option value="5" <? echo $options->table_entries == 5 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_5' ); ?></option>
	  <option value="10" <? echo $options->table_entries == 10 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_10' ); ?></option>
	  <option value="20" <? echo $options->table_entries == 20 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_20' ); ?></option>
	  <option value="50" <? echo $options->table_entries == 50 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_50' ); ?></option>
	  <option value="100" <? echo $options->table_entries == 100 ? "selected=\"selected\"":""?>><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_SELECT_100' ); ?></option>
	</select>
<?php
	echo '</p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="table_role_check" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_ROLES' ).'</label>';
	echo '<input class="radio" type="radio" '.(($options->table_role_check ==0)?"checked=\"checked\"":"").' value="0" name="table_role_check" id="table_role_check" tabindex="7"><label class="inside" for="table_role_check0">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_YES' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_role_check ==1?"checked=\"checked\"":"").' value="1" name="table_role_check" id="table_role_check" tabindex="8"><label class="inside" for="table_role_check1">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_NO' ).'</label>';
	echo '</p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="table_prof1_check" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_PRO1' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_prof1_check ==0?"checked=\"checked\"":"").' value="0" name="table_prof1_check" id="table_prof1_check" tabindex="7"><label class="inside" for="table_prof1_check0">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_YES' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_prof1_check ==1?"checked=\"checked\"":"").' value="1" name="table_prof1_check" id="table_prof1_check" tabindex="8"><label class="inside" for="table_prof1_check1">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_NO' ).'</label>';
	echo '</p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="table_prof2_check" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_PRO2' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_prof2_check ==0?"checked=\"checked\"":"").' value="0" name="table_prof2_check" id="table_prof2_check" tabindex="7"><label class="inside" for="table_prof2_check0">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_YES' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_prof2_check ==1?"checked=\"checked\"":"").' value="1" name="table_prof2_check" id="table_prof2_check" tabindex="8"><label class="inside" for="table_prof2_check1">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_NO' ).'</label>';
	echo '</p></li>';
	
	echo '<li class="event-summary account-form"><p><label for="table_ilevel_check" class="label option">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_LABEL_ILEVEL' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_ilevel_check ==0?"checked=\"checked\"":"").' value="0" name="table_ilevel_check" id="table_ilevel_check" tabindex="7"><label class="inside" for="table_ilevel_check0">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_YES' ).'</label>';
	echo '<input class="radio" type="radio" '.($options->table_ilevel_check ==1?"checked=\"checked\"":"").' value="1" name="table_ilevel_check" id="table_ilevel_check" tabindex="8"><label class="inside" for="table_ilevel_check1">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_RADIO_NO' ).'</label>';
	echo '</p></li>';
	
	echo '<span class="event-summary account-form"><button type="submit" class="button" value="'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_BUTTON' ).'" name="post" tabindex="14">'.JText::_( 'COM_PBROSTER_ACCOUNT_OPTIONS_FORM_BUTTON' ).'</button></span></form>';
?>	  
		</li>
		  <span class="clear"><!-- --></span>
		</div>
	  </div>
	  <span class="clear"><!-- --></span>
	</div>
  </div>
  </div>
</div>

<?php
  
  }
  
  function showMemberAccountClaims($claims, $option) {
    // get account
    $account =& JFactory::getUser();
	
    HTML_MemberRoster::includeMemberDocs();
	$config = getGuildConfig();

	// Modify breadcrumbs
	$mainframe = &JFactory::getApplication();
	$app =& JFactory::getApplication();
	$pathway =& $app->getPathway();
	$pathway->addItem(JText::_( 'COM_PBROSTER_SUBMENU_ITEM_ACCOUNT_CHARACTERS' ).' @ '.ucfirst($account->name));
	
	$ginfo = getGuildInfo();
	foreach ( $ginfo as $guild ) {
	  // Get faction
	  if ($guild->faction == 0)
	    $faction = "alliance";
	  else
	    $faction = "horde";
	}
	
	// Check template setting
    $template = getRosterTemplateAdjust($config);
	
	$got_main = false;
	
	// See if we have a main character and how many char's
	$num_char=0;
	foreach ( $claims as $char ) {
	  if ($char->ac_type == 1)
	    $got_main = true;
	  $num_char++;
	}
	
?>	
<div class="RosterPage" style="width:<?php echo $config->roster_width; ?>px;<?php echo $template->marginleft.$template->margintop; ?>">
  <div class="content-top">
  <div class="content-trail"> </div>
  <div class="content-bot">
	<div id="profile-wrapper" class="profile-wrapper profile-wrapper-<?php echo $faction; ?>">
	  <div class="profile-sidebar-anchor">
		<div class="profile-sidebar-outer">
		  <div class="profile-sidebar-inner">
			<div class="profile-sidebar-contents">
			  <div class="profile-sidebar-crest">
<?php

	HTML_MemberRoster::headerMenu($config, "claims");

?>
			  </div>
			</div>
		  </div>
		</div>
	  </div>
	  <div class="profile-contents">
		<div class="profile-section-header">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_PAGE_TITLE' ); ?></h3>
		</div>
		<div class="profile-section events">
		
		<li class="event-category category-secondary">
		  <h3 class="category "><?php echo JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_TITLE_CLAIM' ); ?></h3>
		</li>
		
		<div class="profile-box-simple">
<?php
	echo '<div class="content-block"><span class="profile-scroll content-2"><span class="content-title">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_TITLE_CLAIM' ).'</span><span class="content-desc">';
	if ($num_char == 0) {
	  echo '<li class="empty">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_DESC_CLAIM_NOCHAR1' ).'</li>';
	  echo '<li class="empty">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_DESC_CLAIM_NOCHAR2' ).'</li>';
	}
	else if (!$got_main) {
	  echo '<li class="empty">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_DESC_CLAIM' ).' <i>'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_DESC_CLAIM_NOMAIN' ).'</i></li>';
	}
	else
	  echo '<li class="empty">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_SUB_DESC_CLAIM' ).'</li>';
	echo '</span></span></div><span style="height:30px;" class="clear"><!-- --></span>';

	foreach ( $claims as $char ) {
	
	  $talent1 = @unserialize($char->talent_spec1);
	  $talent2 = @unserialize($char->talent_spec2);
				
	  $prime_talent = "";
	  $prime_talent['prim'] = "none";
				
	  if (!isset($talent1['prim'])) {
	    $talent1['prim'] = "";
	    $talent1['active'] = 0;
	  }
	  if (!isset($talent2['prim'])) {
	    $talent2['prim'] = "";
	    $talent2['active'] = 0;
	  }
				  
	  if ($talent1['prim'] != "" && $talent1['active'] == 1)
	    $prime_talent = $talent1;
	  else if ($talent2['prim'] != "" && $talent2['active'] == 1)
	    $prime_talent = $talent2;
	
	  echo '<li class="event-summary system-event">';
	  echo '<div class="event-header">';
	  echo '<p class="time"><span class="datetime">'.$char->last_updated.'</span></p>';
	  echo '<span class="icon-frame">';
	  echo '<a href="'.JRoute::_('index.php?option=com_pbroster&view=character&ch='.$char->name).'"><img width="56" height="56" src="'.return_avatar_src($char->avatar, $char->raceId, $char->genderId).'" alt=""/></a>';
	  echo '<span class="frame"></span></span>';
	  if ($char->ac_type == 1)
	    echo '<span class="checkmark"></span>';
	  echo '<div class="event-header-text">';
	  echo '<h3 class="subheader name color-c'.$char->classId.'">'.$char->name.'</h3>';
	  echo '<div style="margin-top:5px;" class="color-c'.$char->classId.'">'.$char->level.' '.return_race_lang($char->raceId).' '.($prime_talent['prim'] != "none" ? $prime_talent['prim'] : "").' '.return_class_lang($char->classId).'</div>';
	  echo '<div class="claim-actions">';
	  echo '<a style="'.($char->ac_type == 1 ? "display:none;" : "").'" class="set_main-link" href="'.JRoute::_('index.php?option=com_pbroster&view=account&page=setmain&ch='.$char->name).'">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_BUTTON_SETMAIN' ).'</a>';
	  echo '<a class="poplight" rel="edit-'.$char->name.'" href="#?w=500">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_BUTTON_EDIT' ).'</a>';
	  echo '<a class="remove-link" href="'.JRoute::_('index.php?option=com_pbroster&view=account&page=unclaim&ch='.$char->name).'">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_BUTTON_UNCLAIM' ).'</a>';
	  echo '</div></div></div></li>';
	  
	  // Edit popup box
	  echo '<div id="edit-'.$char->name.'" class="popup_block" >';
	  echo '<div class="content-block"><span class="profile-scroll content-3"><span class="content-title">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_POP_TITLE' ).' - '.$char->name.'</span><span class="content-desc">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_POP_DESC' ).'</span></span></div>';
	  echo '<form method="post" action="'.JRoute::_('index.php?option=com_pbroster&view=account&page=edit_char&ch='.$char->name).'" id="form">';
	  echo '<li class="event-summary system-event"><p><label for="screenshotURL" class="label popup">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_POP_LABEL_SCREENSHOT' ).'</label><input class="popup" type="text" id="screenshotURL" value="'.$char->screenshot.'" name="screenshotURL" size="50" maxlength="320" tabindex="1" class="input"/></p></li>';
	  echo '<li class="event-summary system-event"><p><label for="characterComment" class="label popup">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_POP_LABEL_COMMENT' ).'</label><textarea type="text" id="characterComment" name="characterComment" size="50" maxlength="320" tabindex="2" class="input">'.$char->comment.'</textarea></p></li>';
	  echo '<span class="event-summary system-event"><button type="submit" class="button popup" value="Submit" name="post" tabindex="3">'.JText::_( 'COM_PBROSTER_ACCOUNT_CHARACTER_FORM_POP_BUTTON' ).'</button></span>';
	  echo '</form></div>';
	}
	echo '</div>'; // profile-box-simple
?>		
		  <span class="clear"><!-- --></span>
		</div>
	  </div>
	  <span class="clear"><!-- --></span>
	</div>
  </div>
  </div>
</div>
<?php
  }
  
}

?>